package com.borko.healthcare.entities.beans;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;


import com.borko.healthcare.entities.interfaces.Medicine;
import com.borko.healthcare.entities.interfaces.Notification;
import com.borko.healthcare.entities.interfaces.Supplier;
import com.borko.healthcare.entities.interfaces.UserDetails;

@Entity(name = "supplier")
@Table(name = "SUPPLIERS")
public class SupplierBean implements Supplier {
	
	@Id @GeneratedValue
	@Column(name = "SUPPLIER_ID")
	private int id;
	
	@OneToOne(targetEntity = UserDetailsBean.class, optional = false)
	private UserDetails userDetails;
	
	@OneToMany(targetEntity = MedicineBean.class, mappedBy="supplier")
	@LazyCollection(LazyCollectionOption.FALSE)
	private List<Medicine> medicines;
	
	@OneToMany(targetEntity = NotificationBean.class , mappedBy = "supplier")
	@LazyCollection(LazyCollectionOption.FALSE)
	private List<Notification> notifications;
	
	public SupplierBean() {
		this.notifications = new ArrayList<Notification>();
		this.medicines = new ArrayList<Medicine>();
		userDetails = new UserDetailsBean();
	}
	
	public int getId() {
		return id;
	}
	
	public UserDetails getUserDetails() {
		return userDetails;
	}

	public void setUserDetails(UserDetails userDetails) {
		this.userDetails = userDetails;
	}

	public List<Medicine> getMedicines() {
		return medicines;
	}

	public void setMedicines(List<Medicine> medicines) {
		this.medicines = medicines;
	}

	public List<Notification> getNotifications() {
		return notifications;
	}

	public void setNotifications(List<Notification> notifications) {
		this.notifications = notifications;
	}
}
